<?php

namespace app\common\service\store;

use app\admin\model\store\GoodsCouponContact;
use app\common\service\BaseService;

class GoodsCouponContactService extends BaseService
{
    /**
     * Author:Zhongyuan Lu
     * 保存优惠券与商品的关联
     * @param $goodsCouponContact
     * @return array
     */
    public static function saveAll($goodsCouponContact)
    {
        $bool = GoodsCouponContact::insertAll($goodsCouponContact);
        if ($bool) {
            return self::success('添加成功');
        }
        return self::fail('添加失败');
    }

    /**
     * Author:Zhongyuan Lu
     * 根据优惠券id获取对应的商品id
     * @param $couponId
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getGoodsId($couponId)
    {
        $data = GoodsCouponContact::where('coupon_id',$couponId)->column('goods_id');
        return $data;
    }
}